<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <button>发送验证码</button>
</body>
<script>
    //让按钮不能点
    let btn = document.querySelector('button');

    btn.onclick = function () {
        let number = 10;
        let timer=setInterval(() => {
            if (number <= 0) {
                btn.innerHTML = '重新获取';
                btn.disabled = false;
                clearInterval(timer);
                number=10;
            } else {
                btn.disabled = true;
                btn.innerHTML = --number + '秒才能重新发送';
            }
        }, 1000);

    }
</script>

</html>